<?php
namespace Index\Controller;
use Think\Controller;
class SoController extends CommonController {
    public function index(){
    	$q = I('get.q');

    	$words = getWords($q);


    	$sql = "select * from question where ";

    	if($words){
    		foreach ($words as  $row) {
    			$sql .=" title like '%".$row['word']."%' or";
	    	}

	    	$sql = rtrim($sql,'or');
    	}else{

    		$sql .=" title like '%".$q."%'";
    	}

    	
    	$data = M()->query($sql);

    	var_dump($data);

    }
}